/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * 
 * @author lucas.nunes
 * 
 * 
 */
@Entity
@Table(name = "QLTTB_ORGAO_USUARIO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrgaoUsuario.findAll", query = "SELECT o FROM OrgaoUsuario o ORDER BY o.useId"),
    @NamedQuery(name = "OrgaoUsuario.findByUseId", query = "SELECT o FROM OrgaoUsuario o WHERE o.useId = :useId"),
    @NamedQuery(name = "OrgaoUsuario.findByUseOrgId", query = "SELECT o FROM OrgaoUsuario o WHERE o.useOrgId = :useOrgId"),
    @NamedQuery(name = "OrgaoUsuario.findByUseSe", query = "SELECT o FROM OrgaoUsuario o WHERE o.useSe = :useSe"),
    @NamedQuery(name = "OrgaoUsuario.findNotNullSenha", query = "SELECT o FROM OrgaoUsuario o WHERE o.useSe is not null ORDER BY o.useOrgId.orgNm"),
    @NamedQuery(name = "OrgaoUsuario.findNullSenha", query = "SELECT o FROM OrgaoUsuario o WHERE o.useSe is null ORDER BY o.useOrgId.orgNm"),
    @NamedQuery(name = "OrgaoUsuario.deleteByOrgao", query = "DELETE FROM OrgaoUsuario o WHERE o.useOrgId = :useOrgId"),
    @NamedQuery(name = "OrgaoUsuario.findOrgao", query = "SELECT o.useOrgId FROM OrgaoUsuario o WHERE o.useOrgId = :useOrgId")
})
@SequenceGenerator(name = "sequenceOrgaoUsuario", sequenceName = "SQ_QLTTB_ORGAO_USUARIO", allocationSize = 1)

public class OrgaoUsuario implements Serializable {

    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "USE_ID")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceOrgaoUsuario")
    private BigDecimal useId;
    @JoinColumn(name = "USE_ORG_ID", referencedColumnName = "ORG_ID")
    @ManyToOne(optional = false)    
    private Orgao useOrgId;
    @Size(max = 255)
    @Column(name = "USE_SE")
    private String useSe;

    public OrgaoUsuario() {
    }

    public OrgaoUsuario(BigDecimal useId) {
        this.useId = useId;
    }

    public OrgaoUsuario(BigDecimal useId, Orgao useOrgId) {
        this.useId = useId;
        this.useOrgId = useOrgId;
    }

    public BigDecimal getUseId() {
        return useId;
    }

    public void setUseId(BigDecimal useId) {
        this.useId = useId;
    }

    public Orgao getUseOrgId() {
        return useOrgId;
    }

    public void setUseOrgId(Orgao useOrgId) {
        this.useOrgId = useOrgId;
    }

    public String getUseSe() {
        return useSe;
    }

    public void setUseSe(String useSe) {
        this.useSe = useSe;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (useId != null ? useId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrgaoUsuario)) {
            return false;
        }
        OrgaoUsuario other = (OrgaoUsuario) object;
        if ((this.useId == null && other.useId != null) || (this.useId != null && !this.useId.equals(other.useId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + this.useOrgId;
    }
}
